home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 47
/
Freelog047.iso
/
Bas
/
Jeu
/
Aitchu
/
Aitchu[1].swf
/
scripts
/
frame_37
/
DoAction.as
Wrap
Text File
|
2003-06-10
|
27KB
|
905 lines
function CSprite(SpriteMovieClip, ShurikenMovieClip, KeyUp, KeyDown, KeyLeft, KeyRight, KeyShuriken, KeySabre, LivesValue, PowerByLife)
{
var CptArray;
this.NumOfLives = LivesValue;
this.MaxOfPower = PowerByLife;
this.NumOfPower = this.MaxOfPower;
this.XStep = 5;
this.YStep = 5;
this.SwimValue = 0;
this.ArrayCounter = 0;
this.JumpArray = new Array(20,16,8,0,-8,-16,-20);
this.WallJumpArray = new Array(0,15,15,15,15,15,15,15,15);
this.StepArray = new Array(G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING,G_STEP_WHEN_JUMPING);
this.ShurikensArray = new Array();
this.NumOfShurikens = 5;
this.ShurikensSpeed = this.XStep * 3;
CptArray = 0;
while(CptArray < G_MAX_NUM_SHURIKENS)
{
duplicateMovieClip(ShurikenMovieClip,"Shuriken" + (CptArray + 1),16384 + (CptArray + 1));
this.ShurikensArray.push(eval("Shuriken" + (CptArray + 1)));
this.ShurikensArray[CptArray]._visible = 0;
this.ShurikensArray[CptArray].XDirection = 0;
CptArray++;
}
this.HitPlatforms = 0;
this.HitWater = 0;
this.HitPlatformNum = 0;
this.HitWallNum = 0;
this.ThrowShuriken = 0;
this.SabreHit = 0;
this.Direction = G_RIGHT_DIRECTION;
this.Movement = 4;
this.BlinkValue = 0;
this.TouchByEnemyValue = 0;
this.PrevIsJumpingUp = 0;
this.IsJumpingUp = 0;
this.PrevIsJumpingDown = 0;
this.IsJumpingDown = 0;
this.PrevLeftMove = 0;
this.NextLeftMove = 0;
this.PrevRightMove = 0;
this.NextRightMove = 0;
this.UpKey = KeyUp;
this.DownKey = KeyDown;
this.LeftKey = KeyLeft;
this.RightKey = KeyRight;
this.ShurikenKey = KeyShuriken;
this.SabreKey = KeySabre;
this.SabreKeyRelease = 1;
this.Clip = SpriteMovieClip;
this.ClipRightStep = 1;
this.ClipLeftStep = 10;
this.ClipRightBreak = 20;
this.ClipLeftBreak = 30;
this.ClipRightStepJump = 40;
this.ClipRightJump = 50;
this.ClipLeftStepJump = 60;
this.ClipLeftJump = 70;
this.ClipFall = 80;
this.ClipRightStepFall = 90;
this.ClipLeftStepFall = 100;
this.ClipRightSwim = 110;
this.ClipLeftSwim = 120;
this.ClipUpRightSwim = 130;
this.ClipUpLeftSwim = 140;
this.ClipDownRightSwim = 150;
this.ClipDownLeftSwim = 160;
this.ClipRightSwimBreak = 170;
this.ClipLeftSwimBreak = 180;
this.ClipWallToRightJump = 190;
this.ClipWallToLeftJump = 200;
this.ClipWallToRightBreak = 210;
this.ClipWallToLeftBreak = 220;
this.ClipRightThrowShurikenBreak = 230;
this.ClipLeftThrowShurikenBreak = 240;
this.ClipRightSabreBreak = 250;
this.ClipLeftSabreBreak = 260;
}
var G_SCREEN_WIDTH = 400;
var G_SCREEN_HEIGHT = 600;
var G_ALT_KEY = 18;
var G_ENEMY_SCORE_VALUE = 150;
var G_BOSS_SCORE_VALUE = G_ENEMY_SCORE_VALUE * 20;
var G_BOSS_BLINK_VALUE = 10;
var G_LEFT_DIRECTION = 0;
var G_RIGHT_DIRECTION = 1;
var G_MOVE_UP_LEFT = 0;
var G_MOVE_UP = 1;
var G_MOVE_UP_RIGHT = 2;
var G_MOVE_LEFT = 3;
var G_NO_MOVEMENT = 4;
var G_MOVE_RIGHT = 5;
var G_MOVE_DOWN_LEFT = 6;
var G_MOVE_DOWN = 7;
var G_MOVE_DOWN_RIGHT = 8;
var G_STEP_WHEN_JUMPING = 8;
var G_NUM_SHURIKENS_BONUS = 10;
var G_MAX_NUM_SHURIKENS = 15;
var G_RANDOM_BONUS_SHURIKENS = 15;
var G_POWER_BY_LIFE = 2;
var G_NUM_OF_BLINKS = 30;
var G_START_POSITION_X = 75;
var G_START_POSITION_Y = 300;
CSprite.prototype.IsHittingClip = function(MovieClip)
{
var SpriteBounds = this.Clip.getBounds(_root);
return MovieClip.hitTest(SpriteBounds.xMin,SpriteBounds.yMin,true) || MovieClip.hitTest(SpriteBounds.xMin,SpriteBounds.yMax,true) || MovieClip.hitTest(SpriteBounds.xMax,SpriteBounds.yMin,true) || MovieClip.hitTest(SpriteBounds.xMax,SpriteBounds.yMax,true) || MovieClip.hitTest(this.Clip._x,this.Clip._y,true);
};
CSprite.prototype.IsHittingDeathPlatforms = function(DeathPlatformsClipArray)
{
var HitValue;
var SpriteBounds = this.Clip.getBounds(_root);
var Cpt;
HitValue = 0;
Cpt = 0;
while(!HitValue && Cpt < DeathPlatformsClipArray.length)
{
HitValue = DeathPlatformsClipArray[Cpt].hitTest(SpriteBounds.xMin,SpriteBounds.yMin,true) || DeathPlatformsClipArray[Cpt].hitTest(SpriteBounds.xMax,SpriteBounds.yMin,true);
Cpt++;
}
return HitValue;
};
CSprite.prototype.IsGettingShurikens = function(ShurikensMovieClip)
{
var NumShurikensTmp;
var HitValue;
var ShurikensBounds = ShurikensMovieClip.getBounds(_root);
var ClipCurrentFrame = ShurikensMovieClip._currentFrame;
HitValue = this.Clip.hitTest(ShurikensBounds.xMin,ShurikensBounds.yMin,true) || this.Clip.hitTest(ShurikensBounds.xMax,ShurikensBounds.yMin,true) || this.Clip.hitTest(ShurikensBounds.xMin,ShurikensBounds.yMax,true) || this.Clip.hitTest(ShurikensBounds.xMax,ShurikensBounds.yMax,true);
if(ClipCurrentFrame >= 15 && 35 >= ClipCurrentFrame && HitValue)
{
ShurikensMovieClip.gotoAndPlay("ShurikensClipEnd");
NumShurikensTmp = this.NumOfShurikens + G_NUM_SHURIKENS_BONUS;
if(G_MAX_NUM_SHURIKENS < NumShurikensTmp)
{
this.NumOfShurikens = G_MAX_NUM_SHURIKENS;
}
else
{
this.NumOfShurikens += G_NUM_SHURIKENS_BONUS;
}
return 1;
}
return 0;
};
CSprite.prototype.SpriteInit = function(XPos, YPos)
{
this.Clip._x = XPos;
this.Clip._y = YPos;
this.Move(G_NO_MOVEMENT);
};
CSprite.prototype.IsJumping = function()
{
var ClipFrame = this.Clip._currentFrame;
return (ClipFrame == this.ClipRightStepJump || ClipFrame == this.ClipRightJump || ClipFrame == this.ClipLeftJump || ClipFrame == this.ClipLeftStepJump) && !this.FallValue;
};
CSprite.prototype.IsJumpingDown = function()
{
return 0 >= this.JumpArray[this.ArrayCounter];
};
CSprite.prototype.IsEndOfJump = function()
{
return this.ArrayCounter == this.JumpArray.length;
};
CSprite.prototype.IsFalling = function()
{
var ClipFrame = this.Clip._currentFrame;
return ClipFrame == this.ClipFall || ClipFrame == this.ClipRightStepFall || ClipFrame == this.ClipLeftStepFall;
};
CSprite.prototype.IsHittingPlatformsArray = function(PlatformsMovieClipArray)
{
var SpriteBounds = this.Clip.getBounds(_root);
var ClipFrame = this.Clip._currentFrame;
var HitTestValue;
var CptArray;
var CurrentPlatform;
var MiddleClip;
if(ClipFrame == this.ClipLeftStepJump || ClipFrame == this.ClipLeftStepFall)
{
SpriteBounds.xMin += (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
if(ClipFrame == this.ClipRightStepJump || ClipFrame == this.ClipRightStepFall)
{
SpriteBounds.xMax -= (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
MiddleClip = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
HitTestValue = 0;
CptArray = 0;
while(CptArray < PlatformsMovieClipArray.length && !HitTestValue)
{
CurrentPlatform = PlatformsMovieClipArray[CptArray];
HitTestValue = CurrentPlatform.hitTest(SpriteBounds.xMin,SpriteBounds.yMax,true) || CurrentPlatform.hitTest(SpriteBounds.xMax,SpriteBounds.yMax,true) || CurrentPlatform.hitTest(MiddleClip,SpriteBounds.yMax,true);
CptArray++;
}
if(HitTestValue)
{
CptArray--;
this.HitPlatformNum = CptArray;
}
return HitTestValue;
};
CSprite.prototype.IsHittingMovingPlatform = function(MovingPlatformMovieClip)
{
var SpriteBounds = this.Clip.getBounds(_root);
var ClipFrame = this.Clip._currentFrame;
var HitTestValue;
var CptArray;
var CurrentPlatform;
var MiddleClip;
if(ClipFrame == this.ClipLeftStepJump || ClipFrame == this.ClipLeftStepFall)
{
SpriteBounds.xMin += (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
if(ClipFrame == this.ClipRightStepJump || ClipFrame == this.ClipRightStepFall)
{
SpriteBounds.xMax -= (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
MiddleClip = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
return MovingPlatformMovieClip.hitTest(SpriteBounds.xMin,SpriteBounds.yMax,true) || MovingPlatformMovieClip.hitTest(SpriteBounds.xMax,SpriteBounds.yMax,true) || MovingPlatformMovieClip.hitTest(MiddleClip,SpriteBounds.yMax,true);
};
CSprite.prototype.AdjustClipOnPlatform = function(PlatformsMovieClipArray)
{
var CurrentPlatform;
var SpriteBounds = this.Clip.getBounds(_root);
CurrentPlatform = PlatformsMovieClipArray[this.HitPlatformNum];
this.Clip._y += CurrentPlatform._y - SpriteBounds.yMax;
};
CSprite.prototype.IsHittingPlatformsJumpingDown = function(PlatformsMovieClip)
{
var SpriteBounds = this.Clip.getBounds(_root);
var ClipFrame = this.Clip._currentFrame;
var JumpDown;
var Val;
if(ClipFrame == this.ClipLeftStepJump)
{
SpriteBounds.xMin += (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
if(ClipFrame == this.ClipRightStepJump)
{
SpriteBounds.xMax -= (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
return PlatformsMovieClip.hitTest(SpriteBounds.xMin,Cpt,true) || PlatformsMovieClip.hitTest(SpriteBounds.xMax,Cpt,true);
};
CSprite.prototype.IsHittingWater = function(WaterMovieClip)
{
var SpriteBounds = this.Clip.getBounds(_root);
return WaterMovieClip.hitTest(SpriteBounds.xMin,SpriteBounds.yMin,true) || WaterMovieClip.hitTest(SpriteBounds.xMax,SpriteBounds.yMin,true);
};
CSprite.prototype.StartJump = function(JumpMvtKey)
{
this.ArrayCounter = 0;
if(JumpMvtKey == G_MOVE_UP_LEFT)
{
this.Direction = G_LEFT_DIRECTION;
this.Clip.gotoAndStop(this.ClipLeftStepJump);
this.Clip._x -= this.StepArray[this.ArrayCounter];
}
else if(JumpMvtKey == G_MOVE_UP_RIGHT)
{
this.Direction = G_RIGHT_DIRECTION;
this.Clip.gotoAndStop(this.ClipRightStepJump);
this.Clip._x += this.StepArray[this.ArrayCounter];
}
else if(this.Direction == G_LEFT_DIRECTION)
{
this.Clip.gotoAndStop(this.ClipLeftJump);
}
else
{
this.Clip.gotoAndStop(this.ClipRightJump);
}
this.Clip._y -= this.JumpArray[this.ArrayCounter];
this.ArrayCounter = this.ArrayCounter + 1;
};
CSprite.prototype.Jump = function()
{
var ClipFrame = this.Clip._currentFrame;
if(ClipFrame == this.ClipLeftStepJump)
{
this.Clip._x -= this.StepArray[this.ArrayCounter];
}
if(ClipFrame == this.ClipRightStepJump)
{
this.Clip._x += this.StepArray[this.ArrayCounter];
}
this.Clip._y -= this.JumpArray[this.ArrayCounter];
this.ArrayCounter = this.ArrayCounter + 1;
};
CSprite.prototype.StartFall = function()
{
var ClipFrame = this.Clip._currentFrame;
if(ClipFrame == this.ClipLeftStepJump || ClipFrame == this.ClipWallToLeftJump)
{
this.Clip.gotoAndStop(this.ClipLeftStepFall);
this.Clip._x -= G_STEP_WHEN_JUMPING;
}
else if(ClipFrame == this.ClipRightStepJump || ClipFrame == this.ClipWallToRightJump)
{
this.Clip.gotoAndStop(this.ClipRightStepFall);
this.Clip._x += G_STEP_WHEN_JUMPING;
}
else
{
this.Clip.gotoAndStop(this.ClipFall);
}
this.Clip._y += this.YStep * 3;
};
CSprite.prototype.Fall = function()
{
var ClipFrame = this.Clip._currentFrame;
if(ClipFrame == this.ClipLeftStepFall)
{
this.Clip._x -= G_STEP_WHEN_JUMPING;
this.Clip._y += this.YStep * 3;
}
else if(ClipFrame == this.ClipRightStepFall)
{
this.Clip._x += G_STEP_WHEN_JUMPING;
this.Clip._y += this.YStep * 3;
}
else
{
this.Clip._y += this.YStep * 3;
}
};
CSprite.prototype.IsSwimming = function()
{
return this.SwimValue;
};
CSprite.prototype.ApplyPlouf = function(WaterMovieClip, PloufMovieClip)
{
var WaterBounds = WaterMovieClip.getBounds(_root);
PloufMovieClip._x = this.Clip._x;
PloufMovieClip._y = this.Clip._y - 42;
PloufMovieClip.play();
};
CSprite.prototype.EndSwim = function()
{
this.SwimValue = 0;
};
CSprite.prototype.Swim = function(SwimValue)
{
var ClipFrame = this.Clip._currentFrame;
if(SwimValue == G_MOVE_LEFT)
{
this.Direction = G_LEFT_DIRECTION;
if(ClipFrame != this.ClipLeftSwim)
{
this.Clip.gotoAndStop(this.ClipLeftSwim);
}
this.Clip._x -= this.XStep / 2;
}
else if(SwimValue == G_MOVE_RIGHT)
{
this.Direction = G_RIGHT_DIRECTION;
if(ClipFrame != this.ClipRightSwim)
{
this.Clip.gotoAndStop(this.ClipRightSwim);
}
this.Clip._x += this.XStep / 2;
}
else if(SwimValue == G_MOVE_UP_LEFT)
{
this.Direction = G_LEFT_DIRECTION;
if(ClipFrame != this.ClipUpLeftSwim)
{
this.Clip.gotoAndStop(this.ClipUpLeftSwim);
}
this.Clip._x -= this.XStep / 2;
this.Clip._y -= this.YStep / 2;
}
else if(SwimValue == G_MOVE_UP_RIGHT)
{
this.Direction = G_RIGHT_DIRECTION;
if(ClipFrame != this.ClipUpRightSwim)
{
this.Clip.gotoAndStop(this.ClipUpRightSwim);
}
this.Clip._x += this.XStep / 2;
this.Clip._y -= this.YStep / 2;
}
else if(SwimValue == G_MOVE_DOWN_LEFT)
{
this.Direction = G_LEFT_DIRECTION;
if(ClipFrame != this.ClipDownLeftSwim)
{
this.Clip.gotoAndStop(this.ClipDownLeftSwim);
}
this.Clip._x -= this.XStep / 2;
this.Clip._y += this.YStep / 2;
}
else if(SwimValue == G_MOVE_DOWN_RIGHT)
{
this.Direction = G_RIGHT_DIRECTION;
if(ClipFrame != this.ClipDownRightSwim)
{
this.Clip.gotoAndStop(this.ClipDownRightSwim);
}
this.Clip._x += this.XStep / 2;
this.Clip._y += this.YStep / 2;
}
else if(SwimValue == G_MOVE_UP)
{
if(this.Direction == G_LEFT_DIRECTION)
{
if(ClipFrame != this.ClipUpLeftSwim)
{
this.Clip.gotoAndStop(this.ClipUpLeftSwim);
}
}
else if(ClipFrame != this.ClipUpRightSwim)
{
this.Clip.gotoAndStop(this.ClipUpRightSwim);
}
this.Clip._y -= this.YStep / 2;
}
else if(SwimValue == G_MOVE_DOWN)
{
if(this.Direction == G_LEFT_DIRECTION)
{
if(ClipFrame != this.ClipDownLeftSwim)
{
this.Clip.gotoAndStop(this.ClipDownLeftSwim);
}
}
else if(ClipFrame != this.ClipDownRightSwim)
{
this.Clip.gotoAndStop(this.ClipDownRightSwim);
}
this.Clip._y += this.YStep / 2;
}
else
{
if(this.Direction == G_LEFT_DIRECTION)
{
if(ClipFrame != this.ClipLeftSwimBreak)
{
this.Clip.gotoAndStop(this.ClipLeftSwimBreak);
}
}
else if(ClipFrame != this.ClipRightSwimBreak)
{
this.Clip.gotoAndStop(this.ClipRightSwimBreak);
}
this.Clip._y += this.YStep / 4;
}
this.SwimValue = 1;
};
CSprite.prototype.IsJumpingFromWall = function()
{
var ClipFrame = this.Clip._currentFrame;
return ClipFrame == this.ClipWallToRightJump || ClipFrame == this.ClipWallToLeftJump;
};
CSprite.prototype.IsWaitingOnWall = function()
{
var ClipFrame = this.Clip._currentFrame;
return ClipFrame == this.ClipWallToRightBreak || ClipFrame == this.ClipWallToLeftBreak;
};
CSprite.prototype.IsEndWallJump = function()
{
return this.ArrayCounter == this.WallJumpArray.length;
};
CSprite.prototype.IsHittingWallsArray = function(WallsMovieClipArray)
{
var SpriteBounds = this.Clip.getBounds(_root);
var ValX;
var CptArray;
var HitTestValue;
var CurrentWall;
if(this.Direction == G_LEFT_DIRECTION)
{
ValX = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
else
{
ValX = SpriteBounds.xMax - (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
HitTestValue = 0;
CptArray = 0;
while(CptArray < WallsMovieClipArray.length && !HitTestValue)
{
CurrentWall = WallsMovieClipArray[CptArray];
HitTestValue = CurrentWall.hitTest(ValX,SpriteBounds.yMin,true) && CurrentWall.hitTest(ValX,SpriteBounds.yMax,true);
CptArray++;
}
if(HitTestValue)
{
CptArray--;
this.HitWallNum = CptArray;
}
return HitTestValue;
};
CSprite.prototype.AdjustClipOnWall = function(WallsMovieClipArray)
{
var CurrentWall;
var SpriteBounds = this.Clip.getBounds(_root);
CurrentWall = WallsMovieClipArray[this.HitWallNum];
if(this.Direction == G_LEFT_DIRECTION)
{
this.Clip._x += CurrentWall._x - SpriteBounds.xMax;
}
else
{
this.Clip._x += CurrentWall._x - SpriteBounds.xMin;
}
};
CSprite.prototype.IsHittingWallJumping = function(WallMovieClip)
{
var SpriteBounds = this.Clip.getBounds(_root);
var ValX;
var IncVal;
var HitVal;
var Cpt;
if(this.Direction == G_LEFT_DIRECTION)
{
ValX = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
else
{
ValX = SpriteBounds.xMax - (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
}
return WallMovieClip.hitTest(ValX,SpriteBounds.yMin,true) && WallMovieClip.hitTest(ValX,SpriteBounds.yMax,true) && 1 < this.ArrayCounter;
};
CSprite.prototype.StartWaitOnWall = function()
{
this.ArrayCounter = 0;
if(this.Direction == G_LEFT_DIRECTION)
{
this.Clip.gotoAndStop(this.ClipWallToRightBreak);
this.Direction = G_RIGHT_DIRECTION;
}
else
{
this.Clip.gotoAndStop(this.ClipWallToLeftBreak);
this.Direction = G_LEFT_DIRECTION;
}
};
CSprite.prototype.StartWallJump = function(WallMoveValue)
{
this.ArrayCounter = 0;
if(this.Direction == G_LEFT_DIRECTION && WallMoveValue == G_MOVE_LEFT)
{
this.Clip.gotoAndStop(this.ClipWallToLeftJump);
this.Clip._y -= this.WallJumpArray[this.ArrayCounter];
this.ArrayCounter = this.ArrayCounter + 1;
}
else if(this.Direction == G_RIGHT_DIRECTION && WallMoveValue == G_MOVE_RIGHT)
{
this.Clip.gotoAndStop(this.ClipWallToRightJump);
this.Clip._y -= this.WallJumpArray[this.ArrayCounter];
this.ArrayCounter = this.ArrayCounter + 1;
}
else if(WallMoveValue == G_MOVE_DOWN)
{
this.Clip.gotoAndStop(this.ClipFall);
if(this.Direction == G_LEFT_DIRECTION)
{
this.Clip._x -= 15;
}
else
{
this.Clip._x += 15;
}
}
};
CSprite.prototype.WallJump = function()
{
if(this.Direction == G_LEFT_DIRECTION)
{
this.Clip._x -= G_STEP_WHEN_JUMPING + 4;
}
else
{
this.Clip._x += G_STEP_WHEN_JUMPING + 4;
}
this.Clip._y -= this.WallJumpArray[this.ArrayCounter];
this.ArrayCounter = this.ArrayCounter + 1;
};
CSprite.prototype.EndWallJump = function()
{
if(this.Direction == G_LEFT_DIRECTION)
{
this.Clip.gotoAndStop(this.ClipLeftStepFall);
}
else
{
this.Clip.gotoAndStop(this.ClipRightStepFall);
}
};
CSprite.prototype.GetMovementKey = function()
{
if(Key.isDown(this.UpKey) && Key.isDown(this.LeftKey))
{
return G_MOVE_UP_LEFT;
}
if(Key.isDown(this.UpKey) && Key.isDown(this.RightKey))
{
return G_MOVE_UP_RIGHT;
}
if(Key.isDown(this.DownKey) && Key.isDown(this.LeftKey))
{
return G_MOVE_DOWN_LEFT;
}
if(Key.isDown(this.DownKey) && Key.isDown(this.RightKey))
{
return G_MOVE_DOWN_RIGHT;
}
if(Key.isDown(this.RightKey))
{
return G_MOVE_RIGHT;
}
if(Key.isDown(this.LeftKey))
{
return G_MOVE_LEFT;
}
if(Key.isDown(this.UpKey))
{
return G_MOVE_UP;
}
if(Key.isDown(this.DownKey))
{
return G_MOVE_DOWN;
}
return G_NO_MOVEMENT;
};
CSprite.prototype.Move = function(MoveValue)
{
var ClipFrame = this.Clip._currentFrame;
if(MoveValue == G_MOVE_RIGHT)
{
this.Direction = G_RIGHT_DIRECTION;
if(ClipFrame != this.ClipRightStep)
{
this.Clip.gotoAndStop(this.ClipRightStep);
}
this.Clip._x += this.XStep;
}
else if(MoveValue == G_MOVE_LEFT)
{
this.Direction = G_LEFT_DIRECTION;
if(ClipFrame != this.ClipLeftStep)
{
this.Clip.gotoAndStop(this.ClipLeftStep);
}
this.Clip._x -= this.XStep;
}
else if(this.Direction == G_LEFT_DIRECTION)
{
if(ClipFrame != this.ClipLeftBreak)
{
this.Clip.gotoAndStop(this.ClipLeftBreak);
}
}
else if(ClipFrame != this.ClipRightBreak)
{
this.Clip.gotoAndStop(this.ClipRightBreak);
}
};
CSprite.prototype.IsJumpingMove = function(MoveValue)
{
return MoveValue == G_MOVE_UP_LEFT || MoveValue == G_MOVE_UP || MoveValue == G_MOVE_UP_RIGHT;
};
CSprite.prototype.IsThrowingShuriken = function()
{
if(0 < this.ThrowShuriken)
{
return 1;
}
return 0;
};
CSprite.prototype.IsShurikenKeyPressed = function()
{
return Key.isDown(this.ShurikenKey);
};
CSprite.prototype.InitThrowShuriken = function()
{
this.ThrowShuriken = 4;
};
CSprite.prototype.HasShurikens = function()
{
return this.NumOfShurikens;
};
CSprite.prototype.ContinueThrowShuriken = function()
{
this.ThrowShuriken--;
};
CSprite.prototype.IsEndThrowShuriken = function()
{
return !this.ThrowShuriken;
};
CSprite.prototype.CreateShuriken = function()
{
var CptArray;
CptArray = 0;
while(this.ShurikensArray[CptArray]._visible)
{
CptArray++;
}
if(this.Direction == G_RIGHT_DIRECTION)
{
this.ShurikensArray[CptArray].XDirection = 1;
}
else
{
this.ShurikensArray[CptArray].XDirection = -1;
}
this.ShurikensArray[CptArray]._x = this.Clip._x;
this.ShurikensArray[CptArray]._y = this.Clip._y;
this.ShurikensArray[CptArray]._visible = 1;
this.NumOfShurikens--;
};
CSprite.prototype.ClearShurikens = function()
{
var CptArray;
CptArray = 0;
while(CptArray < this.ShurikensArray.length)
{
this.ShurikensArray[CptArray]._visible = 0;
CptArray++;
}
};
CSprite.prototype.MoveShurikens = function()
{
var CptArray;
var InScreen;
CptArray = 0;
while(CptArray < this.ShurikensArray.length)
{
InScreen = this.ShurikensArray[CptArray]._x >= 0 && this.ShurikensArray[CptArray]._x < G_SCREEN_WIDTH;
if(this.ShurikensArray[CptArray]._visible && InScreen)
{
this.ShurikensArray[CptArray]._x += this.ShurikensArray[CptArray].XDirection * this.ShurikensSpeed;
}
else
{
this.ShurikensArray[CptArray]._visible = 0;
}
CptArray++;
}
};
CSprite.prototype.StartThrowShurikenOnPlatforms = function()
{
var CurrentFrame = this.Clip._currentFrame;
if(CurrentFrame == this.ClipRightStep)
{
this.Clip.gotoAndStop(this.ClipRightThrowShurikenBreak);
}
else if(CurrentFrame == this.ClipLeftStep)
{
this.Clip.gotoAndStop(this.ClipLeftThrowShurikenBreak);
}
else if(this.Direction == G_RIGHT_DIRECTION)
{
this.Clip.gotoAndStop(this.ClipRightThrowShurikenBreak);
}
else
{
this.Clip.gotoAndStop(this.ClipLeftThrowShurikenBreak);
}
};
CSprite.prototype.IsSabreKeyPressedAfterRelease = function()
{
if(Key.isDown(this.SabreKey) && this.SabreKeyRelease)
{
this.SabreKeyRelease = 0;
return 1;
}
return 0;
};
CSprite.prototype.TestSabreKeyRelease = function()
{
if(!Key.isDown(this.SabreKey))
{
this.SabreKeyRelease = 1;
}
};
CSprite.prototype.InitSabreHit = function()
{
this.SabreHit = 2;
};
CSprite.prototype.StartSabreHitOnPlatforms = function()
{
var CurrentFrame = this.Clip._currentFrame;
if(CurrentFrame == this.ClipRightStep)
{
this.Clip.gotoAndStop(this.ClipRightSabreBreak);
}
else if(CurrentFrame == this.ClipLeftStep)
{
this.Clip.gotoAndStop(this.ClipLeftSabreBreak);
}
else if(this.Direction == G_RIGHT_DIRECTION)
{
this.Clip.gotoAndStop(this.ClipRightSabreBreak);
}
else
{
this.Clip.gotoAndStop(this.ClipLeftSabreBreak);
}
};
CSprite.prototype.IsHittingWithSabre = function()
{
if(0 < this.SabreHit)
{
return 1;
}
return 0;
};
CSprite.prototype.SabreHit = function(EnemiesObjArray)
{
var HitValue;
var CptArray;
var SpriteBounds;
var CurrentEnemy;
var XValue;
SpriteBounds = this.Clip.getBounds(_root);
if(this.Direction == G_RIGHT_DIRECTION)
{
XValue = SpriteBounds.xMax;
}
else
{
XValue = SpriteBounds.xMin;
}
HitValue = 0;
CptArray = 0;
while(!HitValue && CptArray < EnemiesObjArray.length)
{
CurrentEnemy = EnemiesObjArray[CptArray];
HitValue = CurrentEnemy.Clip.hitTest(XValue,SpriteBounds.yMin,true) || CurrentEnemy.Clip.hitTest(XValue,SpriteBounds.yMax,true) || CurrentEnemy.Clip.hitTest(XValue,SpriteBounds.yMin + (SpriteBounds.yMax - SpriteBounds.yMin) / 2,true);
CptArray++;
}
CptArray--;
if(HitValue)
{
return CptArray;
}
return 0;
};
CSprite.prototype.ContinueSabreHit = function()
{
this.SabreHit -= 1;
};
CSprite.prototype.IsEndSabreHit = function()
{
return !this.SabreHit;
};
CSprite.prototype.IsBlinking = function()
{
return this.BlinkValue;
};
CSprite.prototype.IsTouchedByEnemy = function(ArrayOfEnemiesObj)
{
var HitValue;
var CptArray;
var SpriteBounds;
var CurrentEnemy;
var XValue1;
var XValue2;
var YValue;
var YInc;
SpriteBounds = this.Clip.getBounds(_root);
if(this.Direction == G_RIGHT_DIRECTION)
{
XValue1 = SpriteBounds.xMin;
}
else
{
XValue1 = SpriteBounds.xMax;
}
XValue2 = SpriteBounds.xMin + (SpriteBounds.xMax - SpriteBounds.xMin) / 2;
YInc = (SpriteBounds.yMax - SpriteBounds.yMin) / 3;
HitValue = 0;
CptArray = 0;
while(!HitValue && CptArray < ArrayOfEnemiesObj.length)
{
YValue = SpriteBounds.yMin;
while(!HitValue && YValue < SpriteBounds.yMax)
{
HitValue = ArrayOfEnemiesObj[CptArray].Clip.hitTest(XValue1,YValue,true) || ArrayOfEnemiesObj[CptArray].Clip.hitTest(XValue2,YValue,true);
YValue += YInc;
}
CptArray++;
}
return HitValue;
};
CSprite.prototype.TouchedByEnemyControl = function()
{
this.BlinkValue = G_NUM_OF_BLINKS;
this.NumOfPower--;
};
CSprite.prototype.ContinueBlink = function()
{
if(this.BlinkValue & 1)
{
this.Clip._visible = 1;
}
else
{
this.Clip._visible = 0;
}
this.BlinkValue--;
};